<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	template="/layout/template.xhtml"
	xmlns:a4j="http://richfaces.org/a4j">
	<ui:define name="stylefms">
		<link href="/stylesheet/theme.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/fms.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/panel.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/debug.css" rel="stylesheet" type="text/css" />
	</ui:define>
	<ui:define name="varProjectName">
		<ui:param name="projectName" value="#{appRes['mod.fms.fms.maintenances.ctabancarias']}" />
	</ui:define>
    
	<ui:define name="body">
	

		<a4j:form id="bankAccountGridForm" ajaxSingle="true">
			<rich:panel styleClass="table_back">
				<rich:datascroller align="center" for="bankAccountGrid"
					maxPages="15" page="#{dataTableScrollerBean.scrollerPage}"
					renderIfSinglePage="false" />
					
				<rich:dataTable id="bankAccountGrid"
					value="#{editBankAccount.allBankAccount}" 
					var="bankAccount" rows="10"
					rendered="#{not empty editBankAccount.allBankAccount}">
					
					<rich:column>
						<f:facet name="header">Banco</f:facet>
						<h:outputText value="#{bankAccount.idBank}" />
					</rich:column>
					
					<rich:column>
						<f:facet name="header">NroCuenta</f:facet>
						<h:outputText value="#{bankAccount.accountNumber}" />
					</rich:column>
					
					<rich:column>
						<f:facet name="header">Referencia</f:facet>
						<h:outputText value="#{bankAccount.ref}" />
					</rich:column>
					
					<rich:column>
						<f:facet name="header">Moneda</f:facet>
						<h:outputText value="#{convertAssist.getCurrencyDescById(bankAccount.idCurrency)}" />
					</rich:column>

					<rich:column>
						<f:facet name="header">tipCuenta</f:facet>
						<h:outputText value="#{bankAccount.idAccountType}" />
					</rich:column>
										
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="columnHeader" value="Acciones" />
						</f:facet>
						<h:commandButton id="idCmdBorrar" value="Borrar"
							action="#{editBankAccount.dataToDelete(bankAccount.id)}"
							image="/img/icons/delete_data.png"
							onclick="if (!confirm('Esta usted seguro que quiere borrar el registro ?')) return false" />
						<rich:toolTip value="Borrar" for="idCmdBorrar" />
						<rich:spacer width="10" />
						<a4j:commandLink id="editAction"  
						    action="#{editBankAccount.dataToEdit(bankAccount.id)}"
							oncomplete="#{rich:component('modalPanel')}.show()"
							reRender="modalPanel"
							immediate="true">

							<h:graphicImage id="editImg" url="/img/icons/edit.png"
								styleClass="actionsImages" />
						</a4j:commandLink>
						<rich:toolTip value="Editar" for="editAction" />
					</rich:column>
				</rich:dataTable>
			</rich:panel>
			
		</a4j:form>
		<rich:spacer width="10" />	
		<a4j:form id="bankAccountForm" ajaxSingle="true">
			<rich:panel styleClass="form">	
				<h:panelGrid>
					<div class="attributes">
						<h:panelGrid columns="2">
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Banco</ui:define>
								<h:inputText value="#{editBankAccount.bankAccount.idBank}"
									id="bankAccountCode" 
									required="true" size="5"
									requiredMessage="Favor introduzca un codigo"
									validatorMessage="El codigo no puede ser menor a 1 o mayor a 15">
									<f:validateLength minimum="1" maximum="15" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="bankAccountCode"/>
								</div>
							</s:decorate>
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">NroCuenta</ui:define>
								<h:inputText value="#{editBankAccount.bankAccount.accountNumber}"
									id="bankAccountAccountNumber" 
									required="true" size="10"
									requiredMessage="Favor introduzca el numero de cuenta"
									validatorMessage="El nombre no puede ser menor a 3 o mayor a 15">
									<f:validateLength minimum="3" maximum="15" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="bankAccountAccountNumber"/>
								</div>
							</s:decorate>
							
						</h:panelGrid>
						<h:panelGrid columns="2">					
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Referencia</ui:define>
								<h:inputText value="#{editBankAccount.bankAccount.ref}"
									id="bankAccountRef" 
									required="true" size="5"
									requiredMessage="Favor introduzca referencia"
									validatorMessage="El codigo no puede ser menor a 2 o mayor a 70">
									<f:validateLength minimum="2" maximum="70" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="bankAccountRef"/>
								</div>
							</s:decorate>
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Moneda</ui:define>
								<rich:comboBox 
								    converter="#{currencyConverter}"
								    value="#{editBankAccount.bankAccount.currencyBean}"
									id="bankAccountCurrencyBean" 
									required="false" size="30"
									requiredMessage="Favor introduzca la moneda"
									validatorMessage="El estado no puede ser menor o mayor a 1">
									<f:validateLength minimum="1" maximum="10" />
									<a4j:support event="onblur" />
									<s:selectItems  
									     value="#{withinHolder.currencyList()}" 
									     var="cur" 
									     label="#{cur.descrip}">
							        </s:selectItems>
								</rich:comboBox>
								<div class="msg_container">
								<rich:message for="bankAccountCurrencyBean"/>
								</div>
							</s:decorate>
						</h:panelGrid>
						
                        <h:panelGrid columns="2">					
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">TipCuenta</ui:define>
								<h:inputText value="#{editBankAccount.bankAccount.idAccountType}"
									id="bankAccountAccountType" 
									required="true" size="5"
									requiredMessage="Favor introduzca tipo de cuenta (caja ahorro,ctacorriente)"
									validatorMessage="El codigo no puede ser menor a 2 o mayor a 10">
									<f:validateLength minimum="2" maximum="10" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="bankAccountAccountType"/>
								</div>
							</s:decorate>
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Activo</ui:define>
								<h:selectBooleanCheckbox value="#{editBankAccount.bankAccount.status}" 
								id="bankAccountStatus"
								required="false" 
								validatorMessage="El estado no puede ser menor o mayor a 1">
								<a4j:support event="onblur" />
								</h:selectBooleanCheckbox>
								
								<div class="msg_container">
								<rich:message for="bankAccountStatus"/>
								</div>
							</s:decorate>
						</h:panelGrid>
						
					</div>

						<s:decorate template="/layout/displayButton.xhtml" styleClass="button_form">
							<a4j:commandButton value="Guardar"
								action="#{editBankAccount.saveNewData()}" 
								reRender="bankAccountForm, bankAccountGridForm" 
								styleClass="button"/>
							<rich:spacer width="20px" />
							<h:commandButton value="Cancelar"
								action="#{editBankAccount.cancelData()}" 
								reRender="bankAccountForm, bankAccountGridForm" 
								styleClass="button" />
						</s:decorate>
					
				</h:panelGrid>
			</rich:panel>
		</a4j:form>

		<rich:modalPanel  id="modalPanel"  minwidth="800" minheight="400" 
			resizeable="flase" autosized="true"  >
			<f:facet name="header">
				<h:panelGroup>
					<h:outputText value="Actualizar CtaBancaria" />
				</h:panelGroup>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/img/close.png" style="cursor:pointer"
						id="hideEditApp" />
					<rich:componentControl for="modalPanel"
						attachTo="hideEditApp" operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:panelGroup id="idEditGroup">
			<!--  **** Include of the update page ****  -->
				<a4j:include viewId="/fms/fms/maintenances/fmsBankAccountEdit.xhtml" />
			</h:panelGroup>
		</rich:modalPanel>
	</ui:define>
</ui:composition>